package skelbkim;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

/**
 *
 * @author laimis pratestuotas vaikia..
 */

public class Lenta extends SeleneseTestCase {

	public void setUp() throws Exception {
		setUp("http://www.lenta.lt/", "*firefox");
	}

	public void newNotation(String noticeText, String phone, String name, String noticeTitle, String email) throws Exception {
		selenium.open("/");
		selenium.click("link=naujas skelbimas");
        if (isPageLoude()){
        selenium.type("title", noticeTitle);
        selenium.type("message", noticeText );
        selenium.select("//form[@id='bla']/table/tbody/tr[4]/td[1]/select", "label=Klaipėda");
        selenium.type("name", name);
        selenium.type("phone", phone);
        selenium.type("email", email);
        selenium.select("range", "label=paslaugos");
        selenium.click("link=išsiusti skelbimą");
    }
        selenium.stop();
	}

        private boolean isPageLoude() {
        boolean result = true;
        while (!selenium.isElementPresent("//tbody/tr/td/table/tbody/tr[5]/td/table/tbody/tr/td[5]/form/table/tbody/tr[7]/td/a")) {
                selenium.waitForPageToLoad("5000");
        }
        return result;
    }
}
